package com.gzx.plugin.website.access.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzx.plugin.website.access.bo.GzxAccessLogAddBo;
import com.gzx.plugin.website.access.bo.GzxAccessLogPageBo;
import com.gzx.plugin.website.access.service.GzxAccessLogService;
import com.gzx.plugin.website.access.vo.GzxAccessLogVo;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.common.annotation.CommonNoRepeat;
import vip.xiaonuo.common.pojo.CommonResult;

/**
 * @author zjt
 * @description
 * @date 2025/4/17 16:34
 */
@RestController
@RequestMapping("/website/access")
@RequiredArgsConstructor
public class GzxAccessLogController {

    private final GzxAccessLogService accessLogService;

    @CommonNoRepeat
    @GetMapping("/smsVc/{phone}")
    public CommonResult<Integer> smsVc(@PathVariable String phone, HttpServletRequest httpServletRequest) {
        return CommonResult.data(accessLogService.smsVc(phone, httpServletRequest));
    }

    @CommonNoRepeat
    @PostMapping("/verifySmsVc")
    public CommonResult<String> verifySmsVc(@RequestBody GzxAccessLogAddBo accessLogAddBo, HttpServletRequest httpServletRequest) {
        return CommonResult.data(accessLogService.verifySmsVc(accessLogAddBo, httpServletRequest));
    }

    @PostMapping("/log/pageList")
    public CommonResult<Page<GzxAccessLogVo>> pageList(@RequestBody GzxAccessLogPageBo accessLogPageBo) {
        return CommonResult.data(accessLogService.pageList(accessLogPageBo));
    }

    @PostMapping("/log/exportAccessLog")
    public void exportAccessLog(@RequestBody GzxAccessLogPageBo accessLogPageBo, HttpServletResponse httpServletResponse) {
        accessLogService.exportAccessLog(accessLogPageBo, httpServletResponse);
    }
}
